home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / conquest / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-10-26  |  16.8 KB  |  698 lines

  1. /*conquest is copyrighted 1986 by Ed Barlow.
  2.  *  I spent a long time writing this code & I hope that you respect this.  
  3.  *  I give permission to alter the code, but not to copy or redistribute
  4.  *  it without my explicit permission.  If you alter the code, 
  5.  *  please document changes and send me a copy, so all can have it.  
  6.  *  This code, to the best of my knowledge works well,  but it is my first
  7.  *  'C' program and should be treated as such.  I disclaim any
  8.  *  responsibility for the codes actions (use at your own risk).  I guess
  9.  *  I am saying "Happy gaming", and am trying not to get sued in the process.
  10.  *                                                Ed
  11.  */
  12.  
  13. /*include files*/
  14. #include <ctype.h>
  15. #include "header.h"
  16.  
  17. /*initialization data*/
  18. /*Movement costs*/
  19. char *ele=       "#^%-~";
  20. char *elename[]= {  "PEAK", "MOUNTAIN", "HILL", "FLAT","WATER"};
  21. char *veg=       "VDW46973JSI~";
  22. char *vegname[]= { "VOLCANO", "DESERT", "WASTE", "BARREN(4)", "LT VEG(6)",
  23. "GOOD (9)", "WOOD (7)", "FOREST(3)", "JUNGLE", "SWAMP", "ICE", "NONE"};
  24. char *numbers=   "0123456789";
  25. char *Class[]= { "NPC", "king", "emperor", "wizard", "priest", "pirate", 
  26. "trader", "tyrant", "demon", "dragon", "shadow"};
  27. char *races[]= { "GOD","ORC","ELF","DWARF","LIZARD",
  28. "HUMAN","PIRATE","BARBARIAN","NOMAD","UNKNOWN"};
  29. char *diploname[]= { "UNMET", "CONFEDERACY", "ALLIED", "FRIENDLY",
  30. "NEUTRAL", "HOSTILE", "WAR", "JIHAD"};
  31. char *soldname[]= { "","MARCH","SCOUT","ATTACK","DEFEND","GARRISON"};
  32. char *des=       "cCmfx$!-";
  33. char *desname[]= {"CITY", "CAPITOL", "MINE", "FARM", "DEVASTATED", "GOLDMINE", 
  34. "CASTLE", "NODESIG", "PEAK", "WATER"};
  35.  
  36. /*Declarations*/
  37. struct s_sector sct[MAPX][MAPY];
  38. struct nation ntn[NTOTAL];   /* player nation stats */
  39.  
  40. /*is sector occupied by an army?*/
  41. short occ[MAPX][MAPY];
  42. short movecost[MAPX][MAPY];
  43. extern int armornvy;
  44. int startgold=0;
  45.  
  46. /*offset of upper left hand corner*/
  47. short xoffset=0,yoffset=0;
  48. /*current cursor postion (relative to 00 in upper corner)*/
  49. /*    position is 2*x,y*/
  50. short xcurs=0,ycurs=0;
  51. /*redraw map in this turn if redraw is a 1*/
  52. short redraw=TRUE;
  53. /*1 if you have quit*/
  54. int done=0;
  55. /*display state*/
  56. short hilmode=0;   /*highlight modes: 0=owned sectors, 1= armies, 2=none*/
  57. short dismode=2;   /*display mode: 1=vegitation, 2=desig, 3=contour*/
  58. /*         4=armies/navies, 5=commodities, 6=fertility*/
  59. short selector=0;  /*selector (y vbl) for which army/navy... is "picked"*/
  60. /* nation id of owner*/
  61. short country=0;
  62.  
  63. FILE *fexe, *fopen();
  64.  
  65. main(argc,argv)
  66. int argc;
  67. char **argv;
  68. {
  69.     register int i;
  70.     char name[20];
  71.     void srand();
  72.     int getopt();
  73.     char passwd[20];
  74.     long time();
  75.  
  76.     srand((unsigned) time((long *) 0));
  77.     /* process the command line arguments */
  78.     while((i=getopt(argc,argv,"maxph"))!=EOF) switch(i){
  79.     case 'm':  /*make a new world*/
  80.         makeworld();
  81.         exit(1);
  82.     case 'a': /*anyone with password can add player*/
  83.         readdata();
  84.         if(strncmp(crypt(getpass("\nwhat is super user password:"),SALT),ntn[0].passwd,PASSLTH)!=0) {
  85.             printf("sorry, must be super user to add player\n");
  86.             exit(1);
  87.         }
  88.         newlogin();
  89.         exit(1);
  90.     case 'x': /* execute program*/
  91.         readdata();
  92.         update();
  93.         writedata();
  94.         exit(1);
  95.     case 'p': /*print the map*/
  96.         readdata();
  97.         if(strncmp(crypt(getpass("\nwhat is super user password:"),SALT),ntn[0].passwd,PASSLTH)!=0) {
  98.             printf("sorry, must be super user to get map\n");
  99.             exit(1);
  100.         }
  101.         printf("what type of map\noptions are\n");
  102.         printf("\t1) altitudes\n\t2) vegitations\n");
  103.         printf("\t3) nations\n\n");
  104.         printf("\tINPUT:");
  105.         scanf("%hd",&dismode);
  106.         if(dismode==1) printele();
  107.         else if(dismode==2) printveg();
  108.         else pr_ntns();
  109.         exit(1);
  110.     case 'h': /* execute help program*/
  111.         initscr();
  112.         savetty();
  113.         noecho();
  114.         raw();
  115.         help();
  116.         endwin();
  117.         putchar('\n');
  118.         exit(1);
  119.     case '?': /* print out command line arguments */
  120.         printf("Cmd line format: conquest [-maxdhp]\n\t-m   make a world\n\t-a   add new player\n\t-x   execute program\n\t-h   print help text\n\t-p   print a map\n ");
  121.         exit(1);
  122.     };
  123.  
  124.     /* read data*/
  125.     readdata();
  126.     armornvy=AORN;
  127.  
  128.     /* identify the player and the country he represents */
  129.  
  130.     /* get nation name either from command line or by asking
  131.  *     if you fail will give you the name of administrator of game
  132.  */
  133.  
  134.     /* verify existence of nation*/
  135.     printf("conquest: copyrighted by Ed Barlow (1986)\n");
  136.     printf("what nation would you like to be:");
  137.     scanf("%s",name);
  138.     if(strcmp(name,"god")==0) strcpy(name,"unowned");
  139.     country=(-1);
  140.     for(i=0;i<NTOTAL;i++)
  141.         if(strcmp(name,ntn[i].name)==0) country=i;
  142.  
  143.     if(country==(-1)) {
  144.         printf("name not found\n");
  145.         printf("\nfor rules type <conquest -h>");
  146.         printf("\nfor more information please contact %s\n",OWNER);
  147.         return;
  148.     }
  149.  
  150.     /*get encrypted password*/
  151.     strcpy(passwd,crypt(getpass("\nwhat is your password:"),SALT));
  152.     if((strncmp(passwd,ntn[country].passwd,PASSLTH)!=0)&&(strncmp(passwd,ntn[0].passwd,PASSLTH)!=0)) {
  153.         strcpy(passwd,crypt(getpass("\nerror: reenter your password:"),SALT));
  154.         if((strncmp(passwd,ntn[country].passwd,PASSLTH)!=0)&&(strncmp(passwd,ntn[0].passwd,PASSLTH)!=0)) {
  155.             printf("\nsorry:");
  156.             printf("\nfor rules type <conquest -h>");
  157.             printf("\nfor more information on the system please contact %s\n",OWNER);
  158.             exit(1);
  159.         }
  160.     }
  161.  
  162.     /* check if user is super-user nation[0] */
  163.     /*     else setup cursor to capitol*/
  164.     if(country==0) {
  165.         printf("welcome super user\n");
  166.         xcurs=1;
  167.         xoffset=0;
  168.         ycurs=1;
  169.         yoffset=0;
  170.     }
  171.     else {
  172.         printf("\nverifing that nation %s exists\n",ntn[country].name);
  173.         startgold = ntn[country].tgold;
  174.         execute();
  175.         if(ntn[country].capx>15) {
  176.             xcurs=15;
  177.             xoffset= (ntn[country].capx-15);
  178.         }
  179.         else {
  180.             xcurs= ntn[country].capx;
  181.             xoffset= 0;
  182.         }
  183.         if(ntn[country].capy>10) {
  184.             ycurs=10;
  185.             yoffset= (ntn[country].capy-10);
  186.         }
  187.         else {
  188.             yoffset= 0;
  189.             ycurs= ntn[country].capy;
  190.         }
  191.     }
  192.  
  193.     updmove(ntn[country].race);
  194.  
  195.     /* open output for future printing*/
  196.     if ((fexe=fopen(EXEFILE,"a"))==NULL) {
  197.         beep();
  198.         printf("error opening %s\n",EXEFILE);
  199.         exit(1);
  200.     }
  201.  
  202.     /* SET UP THE SCREEN */
  203.     printf("about to set up the screen");
  204.     initscr();
  205.     savetty();
  206.     raw();
  207.  
  208.     prep();
  209.     noecho();
  210.  
  211.     /*main while routine*/
  212.     done=0;
  213.     while (done==0)
  214.     {
  215.         /* check if cursor is out of bounds*/
  216.         if((xcurs<1)||(ycurs<1)||(xcurs>=(COLS-21)/2)||((ycurs>=LINES-5))||((XREAL)>=MAPX)||((YREAL)>=MAPY)) offmap();
  217.  
  218.         /*update map*/
  219.         if(redraw==TRUE) {
  220.             clear();
  221.             makemap();    /* update map*/
  222.             makebottom();
  223.             redraw=FALSE;
  224.         }
  225.         move(ycurs,2*xcurs);
  226.         makeside(); /*update side*/
  227.         move(ycurs,2*xcurs);
  228.         refresh();
  229.         /*get commands, make moves and input command*/
  230.         parse();
  231.     }
  232.  
  233.     if(country==0) writedata();
  234.     else {
  235.     fprintf(fexe,"NGOLD\t%d \t%d \t%d \t0 \t0 \t%s\n",XNAGOLD ,country,ntn[country].tgold,"null");
  236.     fprintf(fexe,"NIRON\t%d \t%d \t%d \t0 \t0 \t%s\n",XNAIRON ,country,ntn[country].tiron,"null");
  237.     fprintf(fexe,"NRGOLD\t%d \t%d \t%d \t0 \t0 \t%s\n",XNARGOLD ,country,ntn[country].jewels,"null");
  238.     }
  239.     /*done so quit*/
  240.     clear();
  241.     printw("quitting\n");
  242.     refresh();
  243.     noraw();
  244.     resetty();
  245.     endwin();
  246.     fclose(fexe);
  247.     exit(1);
  248. }
  249.  
  250. /*make the bottom of the screen*/
  251. makebottom()
  252. {
  253.     move(LINES-4,0);
  254.     clrtoeol();
  255.     mvprintw(LINES-3,0,"Conquest version %d",VERSION);
  256.     clrtoeol();
  257.     mvaddstr(LINES-1,0,"  type ? for help");
  258.     clrtoeol();
  259.     mvaddstr(LINES-2,0,"  type Q to quit");
  260.     clrtoeol();
  261.     if(country==0) mvaddstr(LINES-3,COLS-20,"nation..GOD  ");
  262.     else {
  263.         mvprintw(LINES-3,COLS-20,"nation...%s",ntn[country].name);
  264.         mvprintw(LINES-2,COLS-20,"treasury.%d",ntn[country].tgold);
  265.         mvprintw(LINES-1,COLS-20,"score....%d",ntn[country].score);
  266.     }
  267. }
  268.  
  269. /* parse */
  270. parse()
  271. {
  272.     register int i;
  273.     char name[20];
  274.     char passwd[12];
  275.     int ocountry;
  276.  
  277.     switch(getch()) {
  278.     case ' ':    /*redraw the screen*/
  279.         redraw=TRUE;
  280.         break;
  281.     case 'a':    /*army report*/
  282.         redraw=TRUE;
  283.         armyrpt();
  284.         break;
  285.     case 'A':    /*adjust army*/
  286.         redraw=TRUE;
  287.         adjarm();
  288.         break;
  289.     case 'b':    /*move south west*/
  290.         xcurs--;
  291.         ycurs++;
  292.         break;
  293.     case 'B':    /*budget*/
  294.         redraw=TRUE;
  295.         budget();
  296.         break;
  297.     case 'c':    /*change nation stats*/
  298.         redraw=TRUE;
  299.         change();
  300.         break;
  301.     case 'C':    /*construct*/
  302.         construct();
  303.         break;
  304.     case 'd':    /*change display*/
  305.         newdisplay();
  306.         break;
  307.     case 'D':    /*draft*/
  308.         draft();
  309.         break;
  310.     case 'f': /*report on ships and load/unload*/
  311.         redraw=TRUE;
  312.         fleetrpt();
  313.         break;
  314.     case 'H':    /*scroll west*/
  315.         xcurs-=((COLS-22)/4);
  316.         break;
  317.     case 'h':    /*move west*/
  318.         xcurs--;
  319.         break;
  320.     case 'J':    /*scroll down*/
  321.         ycurs+=((LINES-5)/2);
  322.         break;
  323.     case 'j':    /*move down*/
  324.         ycurs++;
  325.         break;
  326.     case 'k':    /*move up*/
  327.         ycurs--;
  328.         break;
  329.     case 'K':    /*scroll up*/
  330.         ycurs-=((LINES-5)/2);
  331.         break;
  332.     case 'l':    /*move east*/
  333.         xcurs++;
  334.         break;
  335.     case 'L':    /*scroll east*/
  336.         xcurs+=((COLS-22)/4);
  337.         break;
  338.     case 'm':     /*move selected item to new x,y */
  339.         redraw=TRUE;
  340.         mymove();
  341.         prep();
  342.         break;
  343.     case 'M':     /*magic*/
  344.         redraw=TRUE;
  345.         domagic();
  346.         break;
  347.     case 'n':    /*move south-east*/
  348.         ycurs++;
  349.         xcurs++;
  350.         break;
  351.     case 'N':    /*read newspaper */
  352.         redraw=TRUE;
  353.         newspaper();
  354.         break;
  355.     case 'p':    /*pick*/
  356.         selector+=2;
  357.         if((mvinch(selector,COLS-21))!='>') selector=0;
  358.         break;
  359.     case 'P':    /*production*/
  360.         redraw=TRUE;
  361.         produce();
  362.         break;
  363.     case 'Q':    /*quit*/
  364.     case 'q':    /*quit*/
  365.         done=1;
  366.         break;
  367.     case 'r':     /*redesignate*/
  368.         redraw=TRUE;
  369.         redesignate();
  370.         break;
  371.         /*list*/
  372.     case 'R':     /*Read Messages*/
  373.         redraw=TRUE;
  374.         rmessage();
  375.         refresh();
  376.         break;
  377.     case 's':    /*score*/
  378.         redraw=TRUE;
  379.         showscore();
  380.         break;
  381.     case 'S':    /*diplomacy screens*/
  382.         diploscrn();
  383.         redraw=TRUE;
  384.         break;
  385.     case 'u':    /*move north-east*/
  386.         ycurs--;
  387.         xcurs++;
  388.         break;
  389.     case 'W':     /*message*/
  390.         redraw=TRUE;
  391.         wmessage();
  392.         break;
  393.     case 'y':    /*move north-west*/
  394.         ycurs--;
  395.         xcurs--;
  396.         break;
  397.     case 'Z':    /*move civilians up to 2 spaces*/
  398.         redraw=TRUE;
  399.         moveciv();
  400.         break;
  401.     case 'z':    /*login as new user */
  402.         fprintf(fexe,"NGOLD\t%d \t%d \t%d \t0 \t0 \t%s\n",XNAGOLD ,country,ntn[country].tgold,"null");
  403.         redraw=TRUE;
  404.         fprintf(fexe,"NIRON\t%d \t%d \t%d \t0 \t0 \t%s\n",XNAIRON ,country,ntn[country].tiron,"null");
  405.         fprintf(fexe,"NRGOLD\t%d \t%d \t%d \t0 \t0 \t%s\n",XNARGOLD ,country,ntn[country].jewels,"null");
  406.         standout();
  407.         clear();
  408.         mvaddstr(0,0,"change login to : ");
  409.         standend();
  410.         refresh();
  411.         echo();
  412.         scanw("%s",name);
  413.         noecho();
  414.  
  415.         ocountry=country;
  416.         country=(-1);
  417.         if(strcmp(name,"god")==0) country=0;
  418.         else for(i=1;i<NTOTAL;i++)
  419.             if((strcmp(name,ntn[i].name)==0)&&(ntn[i].active>=1))
  420.                 country=i;
  421.  
  422.         if(country==(-1)) {
  423.             mvaddstr(2,0,"name not found");
  424.             country=ocountry;
  425.             break;
  426.         }
  427.  
  428.         /*get password*/
  429.         mvaddstr(2,0,"what is your password:");
  430.         refresh();
  431.         getstr(passwd);
  432.         strcpy(name,crypt(passwd,SALT));
  433.  
  434.         if((strncmp(name,ntn[country].passwd,PASSLTH)!=0)&&(strncmp(name,ntn[0].passwd,PASSLTH)!=0)){
  435.             mvaddstr(3,0,"sorry:");
  436.             refresh();
  437.             country=ocountry;
  438.             break;
  439.         }
  440.  
  441.         readdata();
  442.         startgold = ntn[country].tgold;
  443.         execute();
  444.         updmove(ntn[country].race);
  445.         /*go to that nations capital*/
  446.         if(country!=0) {
  447.             if(ntn[country].capx>15) {
  448.                 xcurs=15;
  449.                 xoffset= (ntn[country].capx-15);
  450.             }
  451.             else {
  452.                 xcurs= ntn[country].capx;
  453.                 xoffset= 0;
  454.             }
  455.             if(ntn[country].capy>10) {
  456.                 ycurs=10;
  457.                 yoffset= (ntn[country].capy-10);
  458.             }
  459.             else {
  460.                 yoffset= 0;
  461.                 ycurs= ntn[country].capy;
  462.             }
  463.         }
  464.         break;
  465.     case '?':    /*display help screen*/
  466.         redraw=TRUE;
  467.         help();
  468.         break;
  469.     default:
  470.         beep();
  471.     }
  472. }
  473.  
  474. makeside()
  475. {
  476.     int i;
  477.     int found=0,nvyfnd=0;
  478.     int enemy;
  479.     int y;
  480.     short armynum;
  481.     short nvynum;
  482.     int count;
  483.     int nfound=0;
  484.  
  485.     /*clear side if you cant see it as you are out of bounds*/
  486.     if(inch()==' ') {
  487.         for(i=0;i<LINES-3;i++){
  488.             move(i,COLS-21);
  489.             clrtoeol();
  490.         }
  491.         return;
  492.     }
  493.  
  494.     /*clear top right hand side each new sector*/
  495.     for(count=0;count<11;count++){
  496.         move(count,COLS-21);
  497.         clrtoeol();
  498.     }
  499.  
  500.     /*check for your armies*/
  501.     for(armynum=0;armynum<MAXARM;armynum++){
  502.         /*show any of your armies in sector*/
  503.         if((ASOLD>0)&&(AXLOC==XREAL)&&(AYLOC==YREAL)) {
  504.             if(nfound<5) {
  505.                 mvaddch(nfound*2,COLS-21,'>');
  506.                 if(selector==nfound*2) standout();
  507.                 mvprintw(nfound*2,COLS-20,"army %d: %d men  ",armynum,ASOLD);
  508.                 mvprintw(nfound*2+1,COLS-20," mv:%d st:%s",AMOVE,*(soldname+ASTAT));
  509.                 clrtoeol();
  510.                 standend();
  511.                 nfound++;
  512.             }
  513.             else mvaddstr(10,COLS-20,"MORE...");
  514.         }
  515.         if((occ[XREAL][YREAL]!=0)&&(occ[XREAL][YREAL]!=country)&&((SOWN==country)||((ASOLD>0)&&(AXLOC<=XREAL+1)&&(AXLOC>=XREAL-1)&&(AYLOC<=YREAL+1)&&(AYLOC>=YREAL-1)))) found=1;
  516.     }
  517.  
  518.     for(nvynum=0;nvynum<MAXNAVY;nvynum++){
  519.         if(((NWAR+NMER)!=0)&&(NXLOC==XREAL)&&(NYLOC==YREAL)) {
  520.             if(nfound<6) {
  521.                 mvaddstr(nfound*2,COLS-21,">");
  522.                 if(selector==nfound*2) standout();
  523.                 mvprintw(nfound*2,COLS-20,"navy %d: move %d",nvynum,NMOVE);
  524.                 clrtoeol();
  525.                 mvprintw(nfound*2+1,COLS-20," war:%d mer:%d",NWAR,NMER);
  526.                 clrtoeol();
  527.                 standend();
  528.                 nfound++;
  529.             }
  530.             else mvaddstr(10,COLS-20,"MORE...");
  531.         }
  532.         if((occ[XREAL][YREAL]!=0)&&(occ[XREAL][YREAL]!=country)&&(sct[XREAL][YREAL].altitude==WATER)&&(NWAR+NMER>0)&&(NXLOC<=XREAL+1)&&(NXLOC>=XREAL-1)&&(NYLOC<=YREAL+1)&&(NYLOC>=YREAL-1)) nvyfnd=1;
  533.     }
  534.  
  535.     count=0;
  536.     if(found==1) for(i=0;i<NTOTAL;i++) {
  537.         if(magic(i,HIDDEN)!=1){
  538.             enemy=0;
  539.             for(armynum=0;armynum<MAXARM;armynum++){
  540.                 if((i!=country)&&(ntn[i].arm[armynum].xloc==XREAL)&&(ntn[i].arm[armynum].yloc==YREAL)&&(ntn[i].arm[armynum].sold>0)) enemy+=ntn[i].arm[armynum].sold;
  541.             }
  542.             if(enemy>0) {
  543.                 if(magic(country,SPY)==1)
  544.                     mvprintw(nfound*2+count,COLS-20,"%s: %d men  ",ntn[i].name,enemy);
  545.                 else if(magic(i,THE_VOID)==1){
  546.                 mvprintw(nfound*2+count,COLS-20,"%s: ?? men  ",ntn[i].name);
  547.                 clrtoeol();
  548.                 }
  549.                 else mvprintw(nfound*2+count,COLS-20,"%s: %d men  ",ntn[i].name,(enemy*(rand()%60+70)/100));
  550.                 count++;
  551.             }
  552.         }
  553.     }
  554.     if(nvyfnd==1) for(i=0;i<MAXNTN;i++) {
  555.         if(magic(i,HIDDEN)!=1){
  556.             for(nvynum=0;nvynum<MAXNAVY;nvynum++){
  557.                 if((ntn[i].arm[nvynum].xloc==XREAL)&&(ntn[i].arm[nvynum].yloc==YREAL)&&(ntn[i].arm[nvynum].sold>0)){
  558.                     if(magic(country,SPY)==1){
  559.                         mvprintw(nfound*2+count,COLS-20,"%s: %d ships  ",ntn[i].name,ntn[i].nvy[nvynum].warships+ntn[i].nvy[nvynum].merchant);
  560.                     }
  561.                     else if(magic(i,THE_VOID)==1){
  562.                     mvprintw(nfound*2+count,COLS-20,"%s: ?? ships",ntn[i].name);
  563.                     clrtoeol();
  564.                     }
  565.                     else mvprintw(nfound*2+count,COLS-20,"%s: %d ships  ",ntn[i].name,(ntn[i].nvy[nvynum].warships+ntn[i].nvy[nvynum].merchant)*(rand()%6+7)/10);
  566.                     count++;
  567.                 }
  568.             }
  569.         }
  570.     }
  571.  
  572.     standend();
  573.     mvprintw(11,COLS-20,"x is %d  ",XREAL);
  574.     mvprintw(11,COLS-11,"y is %d  ",YREAL);
  575.  
  576.     if((country!=0)&&(sct[XREAL][YREAL].altitude=='~')){
  577.         for(y=12;y<=20;y++) mvaddstr(y,COLS-20,"                    ");
  578.         mvaddstr(14,COLS-9,"WATER");
  579.     }
  580.     else {
  581.     if((country!=0)&&(country!=sct[XREAL][YREAL].owner)&&(magic(sct[XREAL][YREAL].owner,THE_VOID)==1)){
  582.         for(y=13;y<=20;y++) mvaddstr(y,COLS-20,"                    ");
  583.     }
  584.     else {
  585.  
  586.         for(y=13;y<=14;y++) mvaddstr(y,COLS-20,"                    ");
  587.  
  588.         for(i=0;i<=7;i++)
  589.             if(sct[XREAL][YREAL].designation==*(des+i)){
  590.             mvprintw(13,COLS-20,"%s",*(desname+i));
  591.             clrtoeol();
  592.             }
  593.  
  594.         if((sct[XREAL][YREAL].owner==country)||(country==0))
  595.         mvprintw(15,COLS-20,"people: %6d",sct[XREAL][YREAL].people);
  596.         else     
  597.         mvprintw(15,COLS-20,"people: %6d",sct[XREAL][YREAL].people*(rand()%60+70)/100);
  598.  
  599.         if((sct[XREAL][YREAL].owner==country)||(sct[XREAL][YREAL].owner==0)||(sct[XREAL][YREAL].owner>=MAXNTN)){
  600.             mvprintw(17,COLS-20,"gold is:   %3d",sct[XREAL][YREAL].gold);
  601.             mvprintw(18,COLS-20,"iron is:   %3d",sct[XREAL][YREAL].iron);
  602.             if(sct[XREAL][YREAL].fortress>0){
  603.             mvprintw(19,COLS-20,"fortress:   %2d",sct[XREAL][YREAL].fortress);
  604.             }
  605.             else mvaddstr(19,COLS-20,"               ");
  606.         }
  607.         else {
  608.         for(y=17;y<=19;y++) mvaddstr(y,COLS-20,"                    ");
  609.         }
  610.     }
  611.  
  612.     standout();
  613.     if(sct[XREAL][YREAL].owner==0) mvaddstr(12,COLS-20,"unowned");
  614.     else mvprintw(12,COLS-20,"owner: %s",ntn[sct[XREAL][YREAL].owner].name);
  615.     standend();
  616.     clrtoeol();
  617.  
  618.     for(i=0;i<=10;i++)
  619.         if(sct[XREAL][YREAL].vegitation==*(veg+i))
  620.         mvprintw(13,COLS-9,"%s",*(vegname+i));
  621.  
  622.     if(sct[XREAL][YREAL].owner!=0) for(i=1;i<=8;i++)
  623.         if(ntn[sct[XREAL][YREAL].owner].race==*(races+i)[0]){
  624.         mvprintw(14,COLS-20,"%s",*(races+i));
  625.         clrtoeol();
  626.         }
  627.  
  628.     for(i=0;i<=4;i++)
  629.         if(sct[XREAL][YREAL].altitude==*(ele+i))
  630.         mvprintw(14,COLS-9,"%s",*(elename+i));
  631.     }
  632.  
  633.     if(movecost[XREAL][YREAL]<0) 
  634.     mvaddstr(16,COLS-20,"YOU CAN'T ENTER HERE");
  635.     else
  636.     mvprintw(16,COLS-20,"move cost:  %2d      ",movecost[XREAL][YREAL]);
  637.  
  638. }
  639.  
  640. offmap()
  641. {
  642.     redraw=FALSE;
  643.     /*set offset offsets can not be < 0*/
  644.     if(xcurs<1){
  645.         if(XREAL<=0) {
  646.             xoffset=0;
  647.             xcurs=0;
  648.         }
  649.         else {
  650.             redraw=TRUE;
  651.             xoffset-=15;
  652.             xcurs+=15;
  653.         }
  654.     }
  655.     else if(xcurs >= (COLS-22)/2){
  656.         if(XREAL<MAPX) {
  657.             redraw=TRUE;
  658.             xoffset+=15;
  659.             xcurs-=15;
  660.         }
  661.     }
  662.     if(XREAL>=MAPX) xcurs=MAPX-1-xoffset;
  663.     if(xoffset<0) xoffset=0;
  664.     if(xcurs<0) xcurs=0;
  665.     else if(xcurs >= (COLS-22)/2) {
  666.         redraw=TRUE;
  667.         xoffset+=15;
  668.         xcurs-=15;
  669.     }
  670.  
  671.     if(ycurs<1){
  672.         if(YREAL<=0) {
  673.             yoffset=0;
  674.             ycurs=0;
  675.         }
  676.         else {
  677.             redraw=TRUE;
  678.             ycurs+=15;
  679.             yoffset-=15;
  680.         }
  681.     }
  682.     else if(ycurs >= LINES-5){
  683.         if(YREAL<MAPY) {
  684.             redraw=TRUE;
  685.             yoffset+=15;
  686.             ycurs-=15;
  687.         }
  688.     }
  689.     if(YREAL>=MAPY) ycurs=MAPY-1-yoffset;
  690.     if(yoffset<0) yoffset=0;
  691.     if(ycurs<0) ycurs=0;
  692.     else if(ycurs >= LINES - 5) {
  693.         redraw=TRUE;
  694.         yoffset+=15;
  695.         ycurs-=15;
  696.     }
  697. }
  698.